Skip to content

Inherit Windows accent color #3812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 11, 2025
Merged

Conversation

corvinsz
Copy link
Member

fixes #3811
With this PR consumers can use the newly added Inherit member for the PrimaryColor and SecondaryColor enum.
Just like with BaseTheme="Inherit" inherit means "take the OS preferences".

This is largely based on how it is done in ControlzEx

Notes:
In the case the value could not be read from the registry, or the conversion (registry value --> C# Color) is somehow failing, the code falls back to SwatchHelper.Lookup.First().Value. One alternative would be to throw an error instead, but I don't think such an "irrelevant" feature should throw an exception.

Example:

<materialDesign:BundledTheme BaseTheme="Inherit"
                             ColorAdjustment="{materialDesign:ColorAdjustment}"
-                            PrimaryColor="DeepPurple"
+                            PrimaryColor="Inherit"
-                            SecondaryColor="Lime" />
+                            SecondaryColor="Inherit" />

I also refactored the BundledTheme class slightly.

-added "Inherit" enum member to SecondaryColor
-added a method to get the Systems accent color
@Keboo Keboo added this to the 5.3.0 milestone Mar 11, 2025
@Keboo Keboo added enhancement release notes Items are likely to be highlighted in the release notes. labels Mar 11, 2025
@Keboo Keboo merged commit ae59e31 into MaterialDesignInXAML:master Mar 11, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement release notes Items are likely to be highlighted in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] BundledTheme option to inherit Windows accent color automatically
2 participants